﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ManCoDocService.cs" company="DST Nexdox">
//   Copyright (c) DST Nexdox. All rights reserved.
// </copyright>
// <summary>
//   Defines the ManCoDocService type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Services
{
  using System;
  using System.CodeDom;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using DocProcessingRepository.Interfaces;
  using Entities;
  using Exceptions;
  using ServiceInterfaces;

  public class ManCoDocService : IManCoDocService
  {
    private readonly IManCoDocRepository manCoDocRepository;

    public ManCoDocService(IManCoDocRepository manCoDocRepository)
    {
      this.manCoDocRepository = manCoDocRepository;
    }

    public ManCoDoc GetManCoDoc(String manCo, String docTypeCode, String docTypeName, String environment)
    {
      try
      {
        return this.manCoDocRepository.GetManCoDoc(manCo, docTypeCode, docTypeName, environment);
      }
      catch (Exception e)
      {
        throw new DocProcessingException("Unable to promote ManCoDocs", e);
      }
    }

    public void PromoteMancoDocs(String manCoDocIds, String sourceAppEnvironMent, String targetAppEnvironment, String userID, String comment)
    {
      try
      {
        this.manCoDocRepository.PromoteMancoDocs(manCoDocIds, sourceAppEnvironMent, targetAppEnvironment, userID, comment);
      }
      catch (Exception e)
      {
        throw new DocProcessingException("Unable to promote ManCoDocs", e);
      }
    }

    public IList<ManCoDoc> GetManCoDocsByManCoCodeEnvironment(String manCoCode, String environment, String userID)
    {
      try
      {
        return this.manCoDocRepository.GetManCoDocsByManCoCodeEnvironment(manCoCode, environment, userID);
      }
      catch (Exception e)
      {
        throw new DocProcessingException("Unable to get ManCoDocs", e);
      }
    }
  }
}
